"""
练习 3.1：姓名 将⼀些朋友的姓名存储在⼀个列表中，并将其命名为
names。依次访问该列表的每个元素，从⽽将每个朋友的姓名都打印
出来。
代码部分：
names = ['布鲁斯' , '大司马' , '陈国汉' , '胡桃','bruno mars']
message = f" my favourite star is {names[-1].title()}"
print(names[0])
print(names[1])
print(names[2])
print(names[3])
print(message)

"""
from idlelib.debugobj import myrepr

"""
练习 3.2：问候语 继续使⽤练习 3.1 中的列表，但不打印每个朋友的
姓名，⽽是为每⼈打印⼀条消息。每条消息都包含相同的问候语，但
抬头为相应朋友的姓名。
代码部分：
names = ['布鲁斯' , '大司马' , '陈国汉' , '陈秋怡','bruno mars']
message1 = f" My favourite star is {names[-1].title()}"
message2 = f" My favourite dog is {names[0].title()}"
message3 = f" My favourite teacher is {names[1].title()}"
message4 = f" My favourite friend is {names[2].title()}"
message5 = f" My favourite girl friend is {names[3].title()}"
print(message1)
print(message2)
print(message3)
print(message4)
print(message5)

"""


"""
练习 3.3：⾃⼰的列表 想想你喜欢的通勤⽅式，如骑摩托⻋或开汽
⻋，并创建⼀个包含多种通勤⽅式的列表。根据该列表打印⼀系列有
关这些通勤⽅式的陈述，如下所⽰。
[I would like to own a Honda motorcycle.]
代码部分：

transports = ['cars','bicycle','motorcycle','train','bus','subway']
message1 = f"I would like to go to school by {transports[-1]}"
message2 = f"My mother always like  going to work by {transports[0]}"
message3 = f"My father always like  going to work by {transports[1]}"
message4 = f"My sister treat her {transports[-1] } like she friend"
print(message1)
print(message2)
print(message3)
print(message4)
print(message1,message2,message3,message4)
"""


"""
练习 3.4：嘉宾名单 如果你可以邀请任何⼈⼀起共进晚餐（⽆论是在
世的还是故去的），你会邀请哪些⼈？请创建⼀个列表，其中包含⾄
少三个你想邀请的⼈，然后使⽤这个列表打印消息，邀请这些⼈都来
与你共进晚餐。
代码部分：
Guest_List = ["bruno mars","justin bieber","ed sheeran","usher"]
message1 = (f"I would like to invite {Guest_List[0].title()} 、{Guest_List[1].title()} "
            f"and {Guest_List[2].title()} to come to  have dinner with me.")
print(message1)
"""


"""
练习 3.5：修改嘉宾名单 你刚得知有位嘉宾⽆法赴约，因此需要另外
邀请⼀位嘉宾。
以完成练习 3.4 时编写的程序为基础，在程序末尾添加函数调⽤
print()，指出哪位嘉宾⽆法赴约。
修改嘉宾名单，将⽆法赴约的嘉宾的姓名替换为新邀请的嘉宾的
姓名。
再次打印⼀系列消息，向名单中的每位嘉宾发出邀请。
代码部分：
Guest_List = ["bruno mars","justin bieber","ed sheeran","usher"]
message1 = (f"I would like to invite {Guest_List[0].title()} 、{Guest_List[1].title()} "
            f"and {Guest_List[2].title()} to come to  have dinner with me.")
print(message1)
miss_guy = Guest_List.pop(0)
message2 = f"The miss guy in the tommorow dinner is {miss_guy.title()}."
print(message2)
Guest_List.insert(0,"maroon five")
message3 = (f"I would like to invite {Guest_List[0].title()} 、{Guest_List[1].title()} "
            f"{Guest_List[2].title()} and {Guest_List[3].title()} to come to  have dinner with me.")
print(message3)
"""


"""
练习 3.6：添加嘉宾 你刚找到了⼀张更⼤的餐桌，可容纳更多的嘉宾
就座。请想想你还想邀请哪三位嘉宾。
以完成练习 3.4 或练习 3.5 时编写的程序为基础，在程序末尾添加函数
调⽤ print()，指出你找到了⼀张更⼤的餐桌。
使⽤ insert() 将⼀位新嘉宾添加到名单开头。
使⽤ insert() 将另⼀位新嘉宾添加到名单中间。
使⽤ append() 将最后⼀位新嘉宾添加到名单末尾。
打印⼀系列消息，向名单中的每位嘉宾发出邀请。
代码部分：
 Guest_List = ["bruno mars","justin bieber","ed sheeran","usher"]
 message1 = (f"I would like to invite {Guest_List[0].title()} 、{Guest_List[1].title()} "
            f"and {Guest_List[2].title()} to come to  have dinner with me.")
print(message1)
 miss_guy = Guest_List.pop(0)
 message2 = f"The miss guy in the tommorow dinner is {miss_guy.title()}."
print(message2)
 Guet_List.insert(0,"maroon five")
message3 = (f"I would like to invite {Guest_List[0].title()} 、{Guest_List[1].title()} "
            f"{Guest_List[2].title()} and {Guest_List[3].title()} to come to  have dinner with me.")
print(message3)
print("I found one bigger dinnner desk , so i can invite more people!")
Guest_List.insert(0,'david tao')
Guest_List.insert(3,"jay")
Guest_List.append("leehom wang")
message4 = (f"I would like to invite {Guest_List[0].title()} 、{Guest_List[1].title()}、"
            f"{Guest_List[2].title()} 、{Guest_List[3].title()} 、{Guest_List[4].title()}、"
            f"{Guest_List[5].title()} and {Guest_List[6].title()} to come to  have dinner with me.")
print(message4)
"""


"""
练习 3.7：缩短名单 你刚得知新购买的餐桌⽆法及时送达，因此只能
邀请两位嘉宾。
1以完成练习 3.6 时编写的程序为基础，在程序末尾添加⼀⾏代码，打印⼀条你只能邀请两位嘉宾共进晚餐的消息。
2使⽤ pop() 不断地删除名单中的嘉宾，直到只有两位嘉宾为⽌。每次从名单中弹出⼀位嘉宾时，都打印⼀条消息，让该嘉宾知道你很抱歉，⽆法邀请他来共进晚餐。
3对于余下两位嘉宾中的每⼀位，都打印⼀条消息，指出他依然在受邀之列。
4使⽤ del 将最后两位嘉宾从名单中删除，让名单变成空的。打印该名单，核实名单在程序结束时确实是空的。 
代码部分：
Guest_List = ["bruno mars","justin bieber","ed sheeran","usher"]
message1 = (f"I would like to invite {Guest_List[0].title()} 、{Guest_List[1].title()} "
            f"and {Guest_List[2].title()} to come to  have dinner with me.")
print(message1)
miss_guy = Guest_List.pop(0)
message2 = f"The miss guy in the tommorow dinner is {miss_guy.title()}."
print(message2)
Guest_List.insert(0,"maroon five")
message3 = (f"I would like to invite {Guest_List[0].title()} 、{Guest_List[1].title()} "
            f"{Guest_List[2].title()} and {Guest_List[3].title()} to come to  have dinner with me.")
print(message3)
print("I found one bigger dinnner desk , so i can invite more people!")
Guest_List.insert(0,'david tao')
Guest_List.insert(3,"jay")
Guest_List.append("leehom wang")
message4 = (f"I would like to invite {Guest_List[0].title()} 、{Guest_List[1].title()}、"
            f"{Guest_List[2].title()} 、{Guest_List[3].title()} 、{Guest_List[4].title()}、"
            f"{Guest_List[5].title()} and {Guest_List[6].title()} to come to  have dinner with me.")
print(message4)
print("I am so sorry , but now i only can invite two people to come to my Evening party")
out_man1 =  Guest_List.pop()
print(f"sorry about that {out_man1.title()} ,see you next time!")
out_man2 =  Guest_List.pop()
print(f"sorry about that {out_man2.title()},see you next time!")
out_man3 =  Guest_List.pop()
print(f"sorry about that {out_man3.title()},see you next time!")
out_man4 =  Guest_List.pop()
print(f"sorry about that {out_man4.title()},see you next time!")
out_man5 =  Guest_List.pop()
print(f"sorry about that {out_man5.title()},see you next time!")
print(f"You are still in the list , i am so happy to see you in the night {Guest_List[0].title()}")
print(f"You are still in the list , i am so happy to see you in the night {Guest_List[1].title()}")
del Guest_List[1]
del Guest_List[0]
print(Guest_List)

"""


"""
练习 3.8：放眼世界 想出⾄少 5 个你想去旅游的地⽅。
将这些地⽅存储在⼀个列表中，并确保其中的元素不是按字⺟顺
序排列的。
1按原始排列顺序打印该列表。不要考虑输出是否整洁，只管打印原始 Python 列表就好。
2使⽤ sorted() 按字⺟顺序打印这个列表，不要修改它。再次打印该列表，核实排列顺序未变。
3使⽤ sorted() 按与字⺟顺序相反的顺序打印这个列表，不要修改它。再次打印该列表，核实排列顺序未变。
4使⽤ reverse() 修改列表元素的排列顺序。打印该列表，核实排列顺序确实变了。
5使⽤ reverse() 再次修改列表元素的排列顺序。打印该列表，核实已恢复到原来的排列顺序。
6使⽤ sort() 修改该列表，使其元素按字⺟顺序排列。打印该列表，核实排列顺序确实变了。
7使⽤ sort() 修改该列表，使其元素按与字⺟顺序相反的顺序排列。打印该列表，核实排列顺序确实变了。
代码部分:
city_name = ["switzerland","japan","maldives","iceland","england"]
print(city_name)
print(sorted(city_name))
print(sorted(city_name,reverse = True))  (*使用代码时括号内删除，格式特殊书上未有)
city_name.reverse()
print(city_name)
city_name.reverse()
print(city_name)
city_name.sort()
print(city_name)
city_name.sort(reverse = True)
print(city_name)
"""


"""
练习 3.9：晚餐嘉宾 选择你为完成练习 3.4〜练习 3.7 ⽽编写的⼀个程
序，在其中使⽤ len() 打印⼀条消息，指出你邀请了多少位嘉宾来共
进晚餐。
代码部分：
Guest_List = ["bruno mars","justin bieber","ed sheeran","usher"]
message1 = (f"I would like to invite {Guest_List[0].title()} 、{Guest_List[1].title()} "
            f"and {Guest_List[2].title()} to come to  have dinner with me.")
print(message1)
miss_guy = Guest_List.pop(0)
message2 = f"The miss guy in the tommorow dinner is {miss_guy.title()}."
print(message2)
Guest_List.insert(0,"maroon five")
message3 = (f"I would like to invite {Guest_List[0].title()} 、{Guest_List[1].title()} "
            f"{Guest_List[2].title()} and {Guest_List[3].title()} to come to  have dinner with me.")
print(message3)
print("I found one bigger dinnner desk , so i can invite more people!")
Guest_List.insert(0,'david tao')
Guest_List.insert(3,"jay")
Guest_List.append("leehom wang")
message4 = (f"I would like to invite {Guest_List[0].title()} 、{Guest_List[1].title()}、"
            f"{Guest_List[2].title()} 、{Guest_List[3].title()} 、{Guest_List[4].title()}、"
            f"{Guest_List[5].title()} and {Guest_List[6].title()} to come to  have dinner with me.")
print(message4)
len(Guest_List)
print(f"In the last,i chose to invite {len(Guest_List)} people to have dinner!")
"""


"""
练习 3.10：尝试使⽤各个函数 想想可存储到列表中的东⻄，如⼭
川、河流、国家、城市、语⾔或你喜欢的任何东⻄。编写⼀个程序，
在其中创建⼀个包含这些元素的列表。然后，⾄少把本章介绍的每个
函数都使⽤⼀次来处理这个列表。
代码部分：
songs = ["love song","just two of us","baby","one time","leave the door open","smoking out the window"]
print("My favourite songs list is in the next:")
print(songs)
print(f"The first song in the list is {songs[0]}")
songs[2] = 'orange moon'
print("Modified songs list is:")
print(songs)
songs.append("Never say Never")
print("The list after adding a music is:")
print(songs)
print("The list after inserting a music is:")
songs.insert(2,"love yourself")
print(songs)
print("The list after deleting a music is:")
del songs[1]
print(songs)

"""